package com.yf.exam.modules.exam.dto.response;

import com.yf.exam.modules.exam.dto.ExamDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Objects;

/**
 * <p>
 * 考试分页响应类
 * </p>
 *
 * @author 聪明笨狗
 * @since 2020-07-25 16:18
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel(value = "在线考试分页响应类", description = "在线考试分页响应类")
public class ExamOnlineRespDTO extends ExamDTO implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 是否通过
     */
    @ApiModelProperty(value = "是否通过", required = true)
    private Boolean passed;

    /**
     * 考试次数
     */
    @ApiModelProperty(value = "当前用户已考试次数", required = true)
    private Integer examCount;

    @ApiModelProperty(value = "对应的考试状态：0.未考试 1.考试中 2.通过 3.未通过", required = true)
    private Integer examStatus;

    @ApiModelProperty(value = "对应的考试状态提示：0.未考试 1.考试中 2.通过 3.未通过", required = true)
    private String examStatusTip;

    public String getExamStatusTip() {
        switch (examStatus) {
            case 0:
                examStatusTip = "未考试";
                break;
            case 1:
                examStatusTip = "考试中";
                break;
            case 2:
                examStatusTip = "通过";
                break;
            case 3:
                examStatusTip = "未通过";
                break;
        }
        return examStatusTip;
    }

    @ApiModelProperty(value = "该考试是否允许进行", required = true)
    private Boolean allowExam;

    @ApiModelProperty(value = "考试对应的申请id(必须为申请已通过的,不通过时则置为null)", required = true)
    private Long applyId;

    @ApiModelProperty(value = "本次申请的状态", required = true)
    private Integer allPass;
    @ApiModelProperty(value = "对应的考试状态提示：0.未考试 1.考试中 2.通过 3.未通过", required = true)
    private String allPassTip;

    public String getAllPassTip() {
        if (Objects.isNull(allPass)) {
            allPassTip = "未考试";
            return allPassTip;
        }
        switch (allPass) {
            case 0:
                allPassTip = "未考试";
                break;
            case 1:
                allPassTip = "考试中";
                break;
            case 2:
                allPassTip = "通过";
                break;
            case 3:
                allPassTip = "未通过";
                break;
        }
        return allPassTip;
    }
}
